﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Core
{
    /// <summary>
    /// Форма просмотра результатов
    /// </summary>
    public partial class ViewForm : Form
    {
        public ViewForm()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Загрузить данные для просмотра
        /// </summary>
        /// <param name="SchClass"></param>
        /// <param name="lesson"></param>
        public void LoadData(SchoolClass SchClass, int lesson)
        {
            try
            {
                this.Text = "Результат: " + SchClass.Study[lesson];
                ResDataGrid.Columns.Clear();
                DataGridViewCellStyle cellstyle = new DataGridViewCellStyle();
                cellstyle.BackColor = Color.WhiteSmoke;
                ResDataGrid.Columns.Add("family","Фамилия");
                ResDataGrid.Columns[ResDataGrid.Columns.Count - 1].DefaultCellStyle = cellstyle;

                cellstyle = new DataGridViewCellStyle();
                cellstyle.BackColor = Color.Silver;
                ResDataGrid.Columns.Add("ball","Балл");
                ResDataGrid.Columns[ResDataGrid.Columns.Count - 1].Width = 60;
                ResDataGrid.Columns[ResDataGrid.Columns.Count - 1].DefaultCellStyle = cellstyle;


                cellstyle = new DataGridViewCellStyle();
                cellstyle.BackColor = Color.Gold;
                ResDataGrid.Columns.Add("place", "Место");
                ResDataGrid.Columns[ResDataGrid.Columns.Count - 1].Width = 60;
                ResDataGrid.Columns[ResDataGrid.Columns.Count - 1].DefaultCellStyle = cellstyle;

                cellstyle = new DataGridViewCellStyle();
                cellstyle.BackColor = Color.GreenYellow;
                ResDataGrid.Columns.Add("bonus", "Бонус");
                ResDataGrid.Columns[ResDataGrid.Columns.Count - 1].Width = 60;
                ResDataGrid.Columns[ResDataGrid.Columns.Count - 1].DefaultCellStyle = cellstyle;

                for (int i = 0; i < SchClass.group.Length; i++)
                {
                    ResDataGrid.Rows.Add();
                    ResDataGrid.Rows[i].Cells[0].Value = SchClass.group[i].Name;
                    ResDataGrid.Rows[i].Cells[1].Value = SchClass.group[i].StudyBall[lesson];
                    ResDataGrid.Rows[i].Cells[2].Value = SchClass.group[i].PupilResult[lesson].Place;
                    ResDataGrid.Rows[i].Cells[3].Value = SchClass.group[i].PupilResult[lesson].Bonus;
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message,"Ошибка");
            }
        }
    }
}